package com.zzptc.sky.bdsjws.activites;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.zzptc.sky.bdsjws.R;
import com.zzptc.sky.bdsjws.activites.base.BaseActivity;
import com.zzptc.sky.bdsjws.utils.DanceWageTimer;
import com.zzptc.sky.bdsjws.views.RatingBar;
import com.zzptc.sky.bdsjws.views.RatingView;

import java.util.Random;

import butterknife.BindView;
import butterknife.OnClick;

public class MainActivity extends BaseActivity {

    @BindView(R.id.rv_count)
    RatingView rvCount;
    @BindView(R.id.tv_num)
    TextView tvNum;
    int one = new Random().nextInt(10) + 1;
    int two = new Random().nextInt(10) + 1;
    int three = new Random().nextInt(10) + 1;
    @BindView(R.id.baibao)
    TextView baibao;

    //    @BindView(R.id.Vp_welcome)
//    ViewPager VpWelcome;
//    @BindView(R.id.linlays)
//    LinearLayout linlays;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        initData();
        Intent intent = new Intent();
        intent.setAction("updateVersion");
        sendBroadcast(intent);
    }

    @Override
    public int getContentView() {
        return R.layout.activity_main;
    }

    @Override
    public void initData() {

    }

    @Override
    public void initView() {
        //根据产生的随机数来定 （>=80）高、(<60)低、(8>one>=60)中  三元运算符  表达式？ 结果一 ：(否则)结果二
        rvCount.addRatingBar(new RatingBar(one, one > 8 ? "清晰度高" : (one < 6) ? "清晰度低" : "清晰度中"));
        rvCount.addRatingBar(new RatingBar(two, two > 8 ? "流畅度高" : (two < 6) ? "流畅度低" : "流畅度中"));
        rvCount.addRatingBar(new RatingBar(three, three > 8 ? "安全度高" : (three < 6) ? "安全度低" : "安全度中"));
        rvCount.show();
        //监听
        rvCount.setAnimatorListener(new RatingView.AnimatorListener() {
            @Override
            public void onRotateStart() {

            }

            @Override
            public void onRotateEnd() {
                int num = (int) ((one * 0.5 + two * 0.3 + three * 0.2) * 10);
//        tvNum.setText(num+"");
                long totalExecuteTime = DanceWageTimer.getTotalExecuteTime(num, 20);
                DanceWageTimer danceWageTimer = new DanceWageTimer(totalExecuteTime, 20, tvNum, num);
                danceWageTimer.start();
            }

            @Override
            public void onRatingStart() {

            }

            @Override
            public void onRatingEnd() {

            }
        });
    }

    @BindView(R.id.tv_lianxiren)
    ImageView tvLianxiren;

    public void skipUserActivity(View view) {
        //Toast.makeText(this, "===", Toast.LENGTH_SHORT).show();
        Intent intent = new Intent();
        intent.setClass(MainActivity.this, UserActivity.class);
        MainActivity.this.startActivity(intent);
    }

    @OnClick(R.id.baibao)
    public void onViewClicked() {
        startActivity(new Intent(this, Baoxiang.class));
    }
}
//setContentView(R.layout.activity_main);    *
//        ButterKnife.bind(this);
//
//
//        //三个圆圈
//        View pointl=null;
//        for(int i=0;i<3;i++){
//            pointl=new View(this);
//            pointl.setEnabled(false);
//            pointl.setBackgroundResource(R.drawable.activity_select);
//            //设置大小
//            LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(10,10);
//            params.leftMargin=10;
//            linlays.addView(pointl,params);
//        }
//        linlays.getChildAt(0).setEnabled(true);
//        //默认第一次进入   第一个圆圈的状态
////        VpWelcome.getChildAt(0).setEnabled(true);
////        VpWelcome.getChildAt(1).setEnabled(false);
////        VpWelcome.getChildAt(2).setEnabled(false);
//        //设置监听
//        VpWelcome.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
//            @Override
//            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
//
//            }
//
//            @Override
//            public void onPageSelected(int position) {
//                for (int i=0;i<3;i++){
//                    if (i==position){
//                        linlays.getChildAt(i).setEnabled(true);
//                    }else {
//                        linlays.getChildAt(i).setEnabled(false);
//                    }
//                }
//            }
//
//            @Override
//            public void onPageScrollStateChanged(int state) {
//
//            }
//        });


//*
//    @Override
//    public int getContentView() {
//        return R.layout.activity_main;
//    }
//
//    @Override
//    public void initData() {
//
//    }//*
//
//    public class WelcomePage extends PagerAdapter {
//       List<View> list;
//        public WelcomePage(List list) {
//            this.list=list;
//        }
//        @Override
//        public void destroyItem(ViewGroup container, int position, Object object) {
////            super.destroyItem(container, position, object);
//            container.removeView(list.get(position));
//        }
//        @Override
//        public Object instantiateItem(ViewGroup container, int position) {
//            container.addView(list.get(position));
//            return list.get(position);
//        }
//        @Override
//        public int getCount() {
//            return list.size();
//        }
//        @Override
//        public boolean isViewFromObject(View view, Object object) {
//
//            return view==object;
//        }
//    }

